#ifndef _H_ICC_
#define _H_ICC_
#include "SourceNum.h"
//#define GROUNDS 8
//#define THETEXTUREWIDTH 2048
//#define THETEXTUREHEIGHT 1536
//
//#define DISTANCE 16
//#define PI 3.1415926
//
//#define ROLEX 6
//#define ROLEY 7
//#define RADIUS 0.5
//
//#define JUMP_HIGHT 2
//
//#define SCREEN_LENGHT 32
//
//#define REQUIRED_SPEED 5
//
//#define  DESERTSTART  6
//#define  SPRITESNUMS  18
//
//#define  MAX_STREET_POINTS 1024
//
//#define PTM_RATIO 32

#include "cocos2d.h"

class ICC
{
	float groudBeBack;
	float thePreValue;
	float theNextValue;
	bool istart;

	float anglex,angley;

	bool isJumping;
	bool couldJump;

	volatile bool startCollision;
	volatile bool shouldDestroy;
	float spriteValue;
	int theNext;

	bool isFellDown;
	float seconds;

	bool isDoubleSpeed;
	bool doubleState;

	float wholeScaleX;
	float wholeScaleY;
public:
	char *userData1;
	char *userData2;

	void setNext(int i);
	int getNext();
	//void printlog();
	static ICC * pIcc;
	static ICC * getShareIcc();

	void initBackandNextValue(float x){
		groudBeBack =0;
		theNextValue = thePreValue = x;
	};
	float getBackValue(){
		return groudBeBack;
	};
	float getPreValue(){
		return thePreValue;
	}
	void setNextValue(float newvalue){
		theNextValue = newvalue;
		groudBeBack = theNextValue - thePreValue;
	};
	void moveOver(){
		thePreValue = theNextValue;
	}

	void setSpriteValue(float y){
		spriteValue = y;
	}
	float getSpriteValue(){
		return spriteValue+0.4;
	}
	void setAngle(float x,float y){
		if (x <0)
		{
			anglex = -x;
			if (y <= 0)
			{
				angley = -y;
			} 
			else
			{angley = y;
			}
		} 
		else if(x>0)
		{
			anglex = x;
			//if (y <=0)
			//	angley = -y;
			//else
			angley = y;
		}
		else if (x == 0)
		{
			//anglex = 1.0;
			//angley = 0.1;
		}
	}
	float getAngle(){
		return atan2f(angley,anglex);
	}

	bool jumpState(){
		return isJumping;
	}
	void jumpStart(){
		isJumping = true;
	}
	void jumpOver(){
		isJumping = false;
	}

	void canStartCollision(bool can){
		startCollision = can;
	}
	bool couldCollision(){
		return startCollision;
	}
	bool getDestroy(){
		return shouldDestroy;
	}

	void setDestroy(bool ishould){
		shouldDestroy = ishould;
	}

	bool getFallDown(){
		return isFellDown;
	}
	void setFallDown(bool is){
		if (is)
		{
			seconds = 1.2f;
		} 
		else
		{
			seconds = 0;
		}
		isFellDown = is;
	}
	float getSeconds(){
		return seconds;
	}
	void setNextSeconds(){
		seconds -= 0.0166f;
		if (seconds < 0)
		{
			seconds = 0.0f;
		}
	}

	void setDoubleSpeed(bool isDouble){
		isDoubleSpeed = isDouble;
	}
	bool getDoubleSpeed(){
		return isDoubleSpeed;
	}
	void setDoubleState(bool is){
		doubleState = is;
	}
	bool getDoubleState(){
		return doubleState;
	}
	void setwholeScale(float fx,float fy){
		wholeScaleX = fx;
		wholeScaleY = fy;
	}
	float getwholeScaleX(){
		return wholeScaleX;
	}
	float getwholeScaleY(){
		return wholeScaleY;
	}
	ICC(void);
	~ICC(void);
};
#endif
